package cn.com.blueInfo.core.config;

import cn.com.blueInfo.core.entity.CurrentLoginUserInfo;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author suxch
 * @since 2025/9/11 20:55
 */
@Data
@Component
public class CommonConfig {

    @Value("${core.super-tenant-id}")
    private Long supperTenantId;

    @Autowired
    private CurrentLoginUserInfo currentLoginUserInfo;

    public boolean isSupper() {
        if (ObjectUtils.isEmpty(currentLoginUserInfo.getTenantId())
                && ObjectUtils.isEmpty(currentLoginUserInfo.getApplicationId())
                && StringUtils.isBlank(currentLoginUserInfo.getLoginName())
                && ObjectUtils.isEmpty(currentLoginUserInfo.getUserId())) {
            return false;
        }
        return !supperTenantId.equals(currentLoginUserInfo.getTenantId());
    }

}
